package logic

import (
	"context"
	"errors"
	"go.uber.org/zap"
	"order_srv/internal/dao"
	"order_srv/internal/svc"
	"order_srv/order"
	"smart-health-platforms/pkg"

	"github.com/zeromicro/go-zero/core/logx"
)

type InvoiceListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewInvoiceListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InvoiceListLogic {
	return &InvoiceListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 未审核发票列表
func (l *InvoiceListLogic) InvoiceList(in *order.InvoiceListRequest) (*order.InvoiceListResponse, error) {
	//业务逻辑
	invoiceList, err := dao.InvoiceList(in)
	if err != nil {
		pkg.Error("发票查询失败", zap.Error(err))
		return nil, errors.New("发票查询失败")
	}
	pkg.Info("发票查询成功", zap.Any("invoiceList", invoiceList))
	return &order.InvoiceListResponse{
		List: invoiceList,
	}, nil
}
